/* 公式预览组件样式 */
.formula-preview-container {
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  height: 100%;
}

/* 预览标题栏 */
.preview-header {
  padding: 12px 16px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.preview-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #495057;
}

/* 复制预览按钮 */
.copy-preview-button {
  padding: 6px 12px;
  background-color: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.copy-preview-button:hover {
  background-color: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.copy-preview-button:active {
  transform: translateY(0);
  box-shadow: none;
}

/* 预览内容区域 */
.preview-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  position: relative;
}

/* 预览公式容器 */
.preview-formula {
  width: 100%;
  max-width: 800px;
  text-align: center;
  transition: all 0.3s ease;
}

/* 加载状态 */
.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  padding: 40px 20px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #1976d2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 错误状态 */
.preview-error {
  display: flex;
  align-items: flex-start;
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  padding: 16px;
  color: #721c24;
  width: 100%;
  max-width: 600px;
}

.error-icon {
  font-size: 24px;
  margin-right: 12px;
  flex-shrink: 0;
}

.error-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
}

.error-message strong {
  display: block;
  margin-bottom: 4px;
}

.error-message p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 空状态 */
.preview-empty {
  text-align: center;
  color: #6c757d;
  padding: 40px 20px;
}

.preview-empty p {
  margin: 0;
  font-size: 14px;
  font-style: italic;
}

/* 预览信息 */
.preview-info {
  padding: 8px 16px;
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
  font-size: 12px;
  color: #6c757d;
  text-align: center;
  flex-shrink: 0;
}

.formula-status {
  display: inline-block;
}

/* KaTeX 渲染样式调整 */
.preview-formula :global(.katex) {
  font-size: 1.2em !important;
}

.preview-formula :global(.katex-display) {
  margin: 0.8em 0 !important;
}

/* 滚动条样式 */
.preview-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.preview-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .formula-preview-container {
    min-height: 150px;
  }
  
  .preview-header {
    padding: 8px 12px;
  }
  
  .preview-title {
    font-size: 14px;
  }
  
  .copy-preview-button {
    padding: 4px 8px;
    font-size: 12px;
  }
  
  .preview-content {
    padding: 16px;
    min-height: 120px;
  }
  
  .preview-formula :global(.katex) {
    font-size: 1.1em !important;
  }
  
  .preview-error {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .error-icon {
    margin-right: 0;
    margin-bottom: 8px;
  }
}

/* 无障碍支持 */
.preview-formula {
  aria-live: "polite";
  aria-atomic: "true";
}

.copy-preview-button {
  aria-label: "复制预览内容";
}

/* 打印样式 */
@media print {
  .formula-preview-container {
    border: none !important;
    box-shadow: none !important;
  }
  
  .preview-header,
  .preview-info {
    display: none !important;
  }
  
  .preview-content {
    padding: 0 !important;
    overflow: visible !important;
    min-height: auto !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .formula-preview-container {
    border: 2px solid #000;
  }
  
  .preview-header,
  .preview-info {
    border-color: #000;
    background-color: #ccc;
  }
  
  .copy-preview-button {
    border: 2px solid #000;
  }
}